package com.moon.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//@Configuration
//public class MqSendEmailConfig {
//
//    @Bean
//    public FanoutExchange sendEmailExchange(){
//        return new FanoutExchange("sendEmailExchange");
//    }
//
//    @Bean
//    public Queue sendEmailQueueA(){
//        return new Queue("sendEmailQueue.A");
//    }
//
//    @Bean
//    public Binding sendEmailBindingA(){
//        return BindingBuilder.bind(sendEmailQueueA()).to(sendEmailExchange());
//    }
//
//    @Bean
//    public Queue sendEmailQueueB(){
//        return new Queue("sendEmailQueue.B");
//    }
//
//    @Bean
//    public Binding sendEmailBindingB(){
//        return BindingBuilder.bind(sendEmailQueueB()).to(sendEmailExchange());
//    }
//
//
//
//}
@Configuration
public class MqSendEmailConfig {
    /**
     *  创建三个队列 ：fanout.A   fanout.B
     *  将三个队列都绑定在交换机 fanoutExchange 上
     *  因为是扇型交换机, 路由键无需配置,配置也不起作用
     */


    @Bean
    public Queue queueA() {
        return new Queue("fanout.A");
    }

    @Bean
    public Queue queueB() {
        return new Queue("fanout.B");
    }

    @Bean
    FanoutExchange fanoutExchange() {
        return new FanoutExchange("fanoutExchange");
    }

    @Bean
    Binding bindingExchangeA() {
        return BindingBuilder.bind(queueA()).to(fanoutExchange());
    }

    @Bean
    Binding bindingExchangeB() {
        return BindingBuilder.bind(queueB()).to(fanoutExchange());
    }

}
